Skip to content

Feature/add test coverage - #1231

Merged
mftee merged 5 commits into
CodeGirlsInc:mainfrom
m-hajjo:feature/add-test-coverage
Aug 26, 2026
Merged

Feature/add test coverage#1231
mftee merged 5 commits into
CodeGirlsInc:mainfrom
m-hajjo:feature/add-test-coverage

Conversation

@m-hajjo

@m-hajjo m-hajjo commented Aug 25, 2026

Copy link
Copy Markdown

PR Description
This pull request addresses several testing gaps in the backend service, significantly improving the project's test coverage and overall code quality. Each of the following tasks was completed and committed separately:

  1. Enhanced Metrics Module Test Coverage
    Moved metrics tests from the root-level mxllv.spec.ts to a dedicated backend/src/metrics/metrics.controller.spec.ts.
    Implemented comprehensive tests for the MetricsController, including assertions for counter increment behavior and the validity of the Prometheus exposition format under concurrent requests.
    Refactored the MetricsController to use prom-client for dynamic and accurate metric tracking.
    Removed the outdated smoke test from mxllv.spec.ts, ensuring that all metrics-related tests are now centralized and robust.
    Closes [BE-153] Metrics module test coverage beyond the placeholder smoke check #1118

  2. Added Tamper-Detection and Wrong-Key Test Coverage for crypto.util
    Created a new test suite for crypto.util in backend/src/common/crypto.util.spec.ts.
    Added critical test cases to crypto.util.spec.ts to cover:
    Tampered-ciphertext rejection: Ensures that decryptBuffer throws an error when the ciphertext has been altered.
    Empty-buffer input: Verifies that the encryption and decryption processes correctly handle empty buffers.
    Oversized input: Confirms that encryptBuffer throws an error when the input buffer is too large.
    Removed the narrow roundtrip test from prismn.spec.ts, as it is now superseded by the more comprehensive test suite.
    Closes [BE-154] crypto.util: no tamper-detection or wrong-key test coverage #1119

  3. Implemented Test Coverage for HttpExceptionFilter
    Created a new test suite for the HttpExceptionFilter in backend/src/common/filters/http-exception.filter.spec.ts.
    Added tests to cover various exception types, including HttpException, generic Error, and BadRequestException from the validation pipe.
    Asserted that the response body never includes stack traces or internal file paths, preventing the leakage of sensitive information.
    Verified that status codes are preserved for HttpException and default to 500 for other errors, ensuring consistent and predictable error responses.
    Closes [BE-155] No test coverage for HttpExceptionFilter's exception-to-response mapping #1120

  4. Added Test Coverage for the Request Logger Middleware
    Created a new test suite for the LoggerMiddleware in backend/src/common/middleware/logger.middleware.spec.ts.
    Asserted that the correlation ID from correlation-id.middleware.ts is included in the logged output, improving traceability.
    Ensured that sensitive headers, such as Authorization and Cookie, are not logged in plaintext, enhancing security.
    Closes [BE-156] No test coverage for the request logger middleware #1121

These changes collectively improve the robustness and reliability of the backend service. I am now ready for any further instructions.

@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@m-hajjo is attempting to deploy a commit to the Mftee's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@m-hajjo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mftee mftee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-hajjo This PR currently has a merge conflict with the main branch (mergeable_state: dirty), so it can't be merged as-is. Could you please rebase or merge main into your branch and resolve the conflicting files? Requesting changes until this is resolved.

@mftee mftee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflict has been resolved and the branch is clean against main now. Good test coverage additions - approving.

@mftee
mftee merged commit 1397a9c into CodeGirlsInc:main Aug 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants